//
// Created by iris on 24-11-4.
//

#ifndef CODEGENERATOR_H
#define CODEGENERATOR_H

#include "AST/AST.h"
#include "llvm/Target/TargetMachine.h"
#include <string>

namespace codegen {

    using namespace ast;

    class CodeGenerator {
        llvm::LLVMContext &Ctx;
        llvm::TargetMachine *TM;

    protected:
        CodeGenerator(llvm::LLVMContext &Ctx,
                      llvm::TargetMachine *TM)
            : Ctx(Ctx), TM(TM) {}

    public:
        static CodeGenerator *create(llvm::LLVMContext &Ctx,
                                     llvm::TargetMachine *TM);

        std::unique_ptr<llvm::Module> run(std::vector<ASTBase*> *CM,
                                          std::string FileName);
    };
}

#endif //CODEGENERATOR_H
